<?php
$form = $this->beginWidget('GxActiveForm', array(
    'id' => 'shoppingCart-form',
    'action' => Yii::app()->createUrl('shoppingcart/create'),
    'enableClientValidation' => true,
    'clientOptions' => array('validateOnSubmit' => true, 'validateOnChange' => true, 'enableAjaxValidation' => true,
    ),
        ));
?>
<div class="formElements">
    <div class="padding20px">
        <div class="common">
            <h3 class="remmarginT font-opensanslt txtfff fnt-size18 linHnml addpaddingB10">Book Now<div id="myloader" style="display:none;" align="center">&nbsp;<img src="<?php echo ThemePath(); ?>/images/ajax-loader.gif" align="absmiddle"></div></h3>
            <input name="class_course_type" id="class_course_type" value="<?php echo $classcoursetype; ?>"  type="hidden" />
            <?php /* show  all vanue name */ ?>
            <?php
            echo CHtml::dropDownList('ShoppingCart[venue_id]', '', $venueDetails, array('class' => 'venueDetail'));
            ?>
            <div class="info-label" id="showVenueDataResult"></div>
        </div>
        <div class="common" id="batchval">
            <?php echo CHtml::dropDownList('batch_start_date', '', $batchStartDateList, array('class' => 'batchDetail')); ?>
        </div>
        <div id="batchDateError"></div>
        <?php if ($classcoursetype == "class") { ?>
            <div class="common" id="batchtimeval">
                <?php
                echo CHtml::dropDownList('batch_starttime', '', $batchStartTimeList, array('class' => 'batchTime'));
                ?>
            </div>
            <div id="batchTimeError"></div>
        <?php } ?>
        <div class="common"id="batchticketval">
            <?php
            echo CHtml::dropDownList('batch_batchseats', '', $batchseatList, array('class' => 'batchSeat'));
            ?>
        </div>
        <div id="batchSeatError"></div>

        <div class="common totalBatchseatsPrice remmarginB txtfff alignR">
            <?php echo ClassBatch::getBatchPriceBySeats($batchId, 1); ?>                            
        </div>
        <div class="common">
            <div class="height1px borB rempaddingB"></div>
        </div>
        <div id="AjaxLoaderbook" style="display:none;"><img src="<?php echo ThemePath(); ?>/images/ajax-loader-mini.gif"></img></div>
        <p class="alignR remmarginB">
            <input type="button" class="btnbook" onclick="return validationBookNow();" value="Book Now" />
        </p>
    </div>
</div>

<?php
$this->endWidget();
?>
<style>
    #AjaxLoaderbook {
        width: 10%;
        position: relative;
        left: 37%; 
        top: 30px; 
    }

</style>						
<script language="javascript">
    function validationBookNow() {
        var checkbatchTime = $( "#batch_starttime option:selected" ).text();
        var checkbookSeat = $("#batch_batchseats").val();
        var batchId = $("#batch_starttime").val();
        var class_course_type = $("#class_course_type").val();
        var bookDateId = $("#batch_start_date option:selected" ).text()
        var batchprice = $("#totalPriceId").val();
        if (batchId != '' && class_course_type != '' && checkbookSeat!='') {           
            jQuery.ajax({
                'type': 'POST',
                'url': "<?php echo Yii::app()->createAbsoluteUrl("shoppingCart/create"); ?>",
                'data': "class_course_type=" + class_course_type + "&ShoppingCart[batch_id]=" + batchId + "&ShoppingCart[booking_seats]=" + checkbookSeat+ "&ShoppingCart[booking_date]=" + bookDateId+ "&ShoppingCart[booking_price]=" + batchprice+"&ShoppingCart[batchTime]="+checkbatchTime,
                'beforeSend': function(jqXHR, settings) {
                    $("#AjaxLoaderbook").show();
                },
                'success': function(data) {
                    $("#AjaxLoaderbook").hide();
                    if (data == "success") {                        
                        openShopCart();
                    }
                },
                'cache': false
            });
        }
    }
</script>